package models.persistence;

import java.util.List;

import javax.persistence.EntityManager;

import enumerators.Tables;

public class StaticQuerries {

//	public static List<Customer> getAllCustomers(EntityManager em) {
//		List<Customer> listCustomers = em.createQuery(
//				"SELECT c FROM Customer c").getResultList();
//		return listCustomers;
//	}
//	
//	public static List<ContractItem> getAllContractItems(EntityManager em) {
//		List<ContractItem> contractItems = em.createQuery(
//				"select ci from ContractItem ci").getResultList();
//		return contractItems;
//	}
	
	
	/**
	 * Geting all items from a table
	 *  
	 * @param em
	 * @param table
	 * @return list of objects each method call cast it to the desired iteme
	 */
	@SuppressWarnings("unchecked")
	public static List<Object> getAllItems(EntityManager em,Tables table){
		List<Object> listObjects = em.createQuery(
				"select obj from "+table+" obj").getResultList();
		return listObjects;
	}
	
}
